package cn.com.sp.demo.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UtilsTestIgnore {

	public static void getDaxieToXiahuaxian(String param){
		Pattern p=Pattern. compile("[A-Z]"); 
		if(param==null ||param.equals("")){ 
		System.out.println("请输入要转换的数据！");
		}
		StringBuilder builder=new StringBuilder(param); 
		Matcher mc=p.matcher(param); 
		int i=0; 
		while(mc.find()){ 
		builder.replace(mc.start()+i, mc.end()+i, "_"+mc.group().toLowerCase()); 
		i++; 
		} 
		if('_' == builder.charAt(0)){ 
		builder.deleteCharAt(0); 
		} 
		System.out.println("转换后的数据为：" + builder.toString());
	}
	
	/**
	 * 首字母大写
	 * 
	 * @param srcStr
	 * @return
	 */
	public static String firstCharacterToUpper(String srcStr) {
		return srcStr.substring(0, 1).toUpperCase() + srcStr.substring(1);
	}

	/**
	 * 替换字符串并让它的下一个字母为大写
	 *
	 * @author tcf
	 * @date 2018年11月12日 上午11:26:51
	 * @param srcStr
	 * @param org
	 */
	public static void getXiahuaxianToDaxie(String srcStr,String org){
		String newString = "";
		if(null == org)
		org = "_";
		int first = 0;
		while (srcStr.indexOf(org) != -1) {
			first = srcStr.indexOf(org);
			if (first != srcStr.length()) {
				newString = newString + srcStr.substring(0, first);
				srcStr = srcStr.substring(first + org.length(), srcStr.length());
				srcStr = firstCharacterToUpper(srcStr);
			}
		}
		newString = newString + srcStr;	
		System.out.println(newString);
	}
	
	
	public static void main(String[] args) {
		UtilsTestIgnore.getDaxieToXiahuaxian("salesOrdersFilmed");
	}
}
